package cn.iocoder.yudao.module.crossborder.srm.api;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.crossborder.srm.api.dto.SupplierDTO;
import cn.iocoder.yudao.module.crossborder.srm.api.dto.SupplierCreateReqDTO;
import cn.iocoder.yudao.module.crossborder.srm.api.dto.PurchaseOrderDTO;
import cn.iocoder.yudao.module.crossborder.srm.api.dto.ContractDTO;
import cn.iocoder.yudao.module.crossborder.srm.enums.ApiConstants;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import java.util.List;

/**
 * 供应商关系管理 API 接口
 *
 * @author LHL
 */
@FeignClient(name = ApiConstants.NAME) // TODO 芋艿：fallbackFactory =
@Tag(name = "RPC 服务 - 供应商关系管理")
public interface SrmApi {

    String PREFIX = ApiConstants.PREFIX + "/srm";

    @GetMapping(PREFIX + "/supplier/get")
    @Operation(summary = "获得供应商")
    @Parameter(name = "id", description = "编号", required = true, example = "1024")
    CommonResult<SupplierDTO> getSupplier(@RequestParam("id") @NotNull Long id);

    @GetMapping(PREFIX + "/supplier/list")
    @Operation(summary = "获得供应商列表")
    @Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048")
    CommonResult<List<SupplierDTO>> getSupplierList(@RequestParam("ids") @NotNull List<Long> ids);

    @PostMapping(PREFIX + "/supplier/create")
    @Operation(summary = "创建供应商")
    CommonResult<Long> createSupplier(@RequestBody @Valid SupplierCreateReqDTO createReq);

    @GetMapping(PREFIX + "/purchase-order/get")
    @Operation(summary = "获得采购订单")
    @Parameter(name = "id", description = "编号", required = true, example = "1024")
    CommonResult<PurchaseOrderDTO> getPurchaseOrder(@RequestParam("id") @NotNull Long id);

    @GetMapping(PREFIX + "/contract/get")
    @Operation(summary = "获得合同")
    @Parameter(name = "id", description = "编号", required = true, example = "1024")
    CommonResult<ContractDTO> getContract(@RequestParam("id") @NotNull Long id);

    @PostMapping(PREFIX + "/supplier/evaluate")
    @Operation(summary = "供应商评估")
    @Parameter(name = "supplierId", description = "供应商编号", required = true, example = "1024")
    @Parameter(name = "score", description = "评估分数", required = true, example = "85")
    @Parameter(name = "comment", description = "评估意见", required = true, example = "表现良好")
    CommonResult<Boolean> evaluateSupplier(@RequestParam("supplierId") @NotNull Long supplierId,
                                          @RequestParam("score") @NotNull Integer score,
                                          @RequestParam("comment") @NotNull String comment);

    @PostMapping(PREFIX + "/supplier/certify")
    @Operation(summary = "供应商认证")
    @Parameter(name = "supplierId", description = "供应商编号", required = true, example = "1024")
    @Parameter(name = "certificationType", description = "认证类型", required = true, example = "ISO9001")
    CommonResult<Boolean> certifySupplier(@RequestParam("supplierId") @NotNull Long supplierId,
                                         @RequestParam("certificationType") @NotNull String certificationType);

    @PostMapping(PREFIX + "/quality/inspect")
    @Operation(summary = "质量检验")
    @Parameter(name = "purchaseOrderId", description = "采购订单编号", required = true, example = "1024")
    @Parameter(name = "result", description = "检验结果", required = true, example = "合格")
    CommonResult<Boolean> qualityInspect(@RequestParam("purchaseOrderId") @NotNull Long purchaseOrderId,
                                        @RequestParam("result") @NotNull String result);

}
